package com.fiume.controller;

import com.fiume.pojo.Checkitem;
import com.fiume.service.CheckitemService;
import com.fiume.support.PageResult;
import com.fiume.support.QueryPageBean;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * \* Created with IntelliJ IDEA.
 * \* @author: fanfan
 * \* Date: 2020/12/28
 * \* Time: 20:05
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
@RestController
@RequestMapping("/checkitem")
public class CheckitemController {

    @DubboReference
    private CheckitemService checkitemService;

    /*
        此方法需要在前端写判断并更换地址值,较为麻烦,可通过mybatis plus的内置方法调用同一方法
        减轻代码量.

    @PostMapping("/add")
    public Boolean add(@RequestBody Checkitem checkitem){
        return checkitemService.save(checkitem);
    }

    @PostMapping("/update")
    public Boolean update(@RequestBody Checkitem checkitem){
        return checkitemService.updateById(checkitem);
    }*/

    @PostMapping("/save")
    public Boolean save(@RequestBody Checkitem checkitem){
        return checkitemService.saveOrUpdate(checkitem);
    }

    @GetMapping("/findAll")
    public List<Checkitem> findAll(){
        return checkitemService.list();
    }

    @PostMapping("/findByPage")
    public PageResult findByPage(@RequestBody QueryPageBean queryPageBean){
        return checkitemService.findByPage(queryPageBean);
    }

    @GetMapping("/deleteById/{id}")
    public Boolean Delete(@PathVariable("id") Long id){
        return checkitemService.removeById(id);
    }
}
